package 寒假刷题;

public class 按奇偶排序数组 {
    public int[] sortArrayByParity(int[] nums) {
        int n = nums.length;
        int[] a = new int[n];
        int j = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i]%2==0){
                a[j++] = nums[i];
            }
        }
        for (int i = 0; i < nums.length; i++) {
            if (nums[i]%2!=0){
                a[j++] = nums[i];
            }
        }
        return a;
    }
}
